﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

using BBEverNote.ViewModels;

namespace BBEverNote.Views
{
    /// <summary>
    /// Interaction logic for MainView.xaml
    /// </summary>
    public partial class MainView : Window
    {
        public MainView()
        {
            InitializeComponent();
            this.ContentRendered += new EventHandler(MainView_ContentRendered);
        }

        void MainView_ContentRendered(object sender, EventArgs e)
        {
            //throw new NotImplementedException();

            MainViewModel viewModel = this.DataContext as MainViewModel;
            LoginWnd loginWnd = new LoginWnd();

            loginWnd.DataContext = this.DataContext;
            loginWnd.Owner = this;
            loginWnd._chkAutoLogOn.IsChecked = viewModel.ENModel.IsAutoLogOn;
            loginWnd._chkRemeberMe.IsChecked = viewModel.ENModel.IsRememberMe;
            loginWnd._txtUserName.Text = viewModel.ENModel.UserName;
            loginWnd._password.Password = viewModel.ENModel.Password;

            this.Hide();

            loginWnd.Show();

//             bool isOk = loginWnd.ShowDialog().Value;
//             if (isOk)
//             {
//                 this.Title += @" ( 欢迎 " + viewModel.ENModel.ENUser.Username + @" )";
//             }
//             else
//             {
//                 this.Close();
//             }
        }

        private void RadioButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
        	// TODO: Add event handler implementation here.

            MainViewModel viewModel = this.DataContext as MainViewModel;
            viewModel.IsOnlySaveTxt = !viewModel.IsOnlySaveTxt;
        }
    }
}
